package com.javapda.c328r.command;

/**
 80x64 01h
160x128 03h
320x240 05h
640x480 07h
 *
 */
public abstract class ComediaPreviewJpegResolution {
	public static final int RES_80x64 = 0x01;
	public static final int RES_160x128 = 0x03;
	public static final int RES_320x240 = 0x05;
	public static final int RES_640x480 = 0x07;
	
	public static int convert(String res) {
		System.out.println("res="+res);
		int resInt = RES_640x480;
		if ( res.toLowerCase().equals("res_80x64") ) { 
			resInt = RES_80x64;
		} else if ( res.toLowerCase().equals("res_160x128") ) {
			resInt = RES_160x128;
		} else if ( res.toLowerCase().equals("res_320x240") ) {
			resInt = RES_320x240;
		} else if ( res.toLowerCase().equals("res_640x480") ) {
			resInt = RES_640x480;
		} else {
			String msg = "Unknown type " + res + " defaulting to 640x480";
			System.err.println(msg);
			throw new RuntimeException("ERROR: unknown preview jpeg resolution code: " + res);
		}
		return resInt;
	}
	public static String convert(int code) {
		if ( code == RES_80x64 ) return "RES_80x64";
		if ( code == RES_160x128 ) return "RES_160x128";
		if ( code == RES_320x240 ) return "RES_320x240";
		if ( code == RES_640x480 ) return "RES_640x480";
		throw new RuntimeException("ERROR: unknown preview jpeg resolution code: " + code);
	}
}
